/*
 * Copyright 2014 NAVER Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hbase;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;



/**
 * @author emeroad
 */
public class ApplicationConfig {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    private static final String CONFIG_FILE_NAME = "application.properties";
    private static final String DEFAULT_LISTEN_IP = "0.0.0.0";

    private Properties properties;
    public static final String requestUrl=SystemConfig.getConfig("requestUrl", "");
    public static final String requestUrl1=SystemConfig.getConfig("requestUrl1", "");
    public static final String requestUrl2=SystemConfig.getConfig("requestUrl2", "");
    public static final String requestUrl3=SystemConfig.getConfig("requestUrl3", "");
    public static final String requestUrl4=SystemConfig.getConfig("requestUrl4", "");
    public static final String requestUrl5=SystemConfig.getConfig("requestUrl5", "");

    public static final String rootAppUrl=SystemConfig.getConfig("rootAppUrl", "");
    public static final String appUrl1=SystemConfig.getConfig("appUrl1", "");
    public static final String appUrl2=SystemConfig.getConfig("appUrl2", "");
    public static final String appUrl3=SystemConfig.getConfig("appUrl3", "");
    public static final String appUrl4=SystemConfig.getConfig("appUrl4", "");
    public static final String appUrl5=SystemConfig.getConfig("appUrl5", "");
    public static final String toAppUrl1=SystemConfig.getConfig("toAppUrl1", "");
    public static final String toAppUrl2=SystemConfig.getConfig("toAppUrl2", "");
    public static final String toAppUrl3=SystemConfig.getConfig("toAppUrl3", "");
    public static final String toAppUrl4=SystemConfig.getConfig("toAppUrl4", "");


    public static final Integer ERROR_RATE =SystemConfig.getConfig("ErrorRate", 30);
    public static final Integer CERT_RATE =SystemConfig.getConfig("CertRate", 1000);
    public static final Integer SLEEP_RATE =SystemConfig.getConfig("SleepRate", 2);
    public static final Integer SLOW_SQL_RATE =SystemConfig.getConfig("SLOW_SQL_RATE", 2);

    public static final Integer ERROR_RATE1 =SystemConfig.getConfig("ErrorRate1", 30);
    public static final Integer CERT_RATE1 =SystemConfig.getConfig("CertRate1", 1000);
    public static final Integer SLEEP_RATE1=SystemConfig.getConfig("SleepRate1", 2);
    public static final Integer SLOW_SQL_RATE1 =SystemConfig.getConfig("SLOW_SQL_RATE1", 2);

    public static final Integer ERROR_RATE2 =SystemConfig.getConfig("ErrorRate2", 30);
    public static final Integer CERT_RATE2 =SystemConfig.getConfig("CertRate2", 1000);
    public static final Integer SLEEP_RATE2 =SystemConfig.getConfig("SleepRate2", 2);
    public static final Integer SLOW_SQL_RATE2 =SystemConfig.getConfig("SLOW_SQL_RATE2", 2);

    public static final Integer ERROR_RATE3 =SystemConfig.getConfig("ErrorRate3", 30);
    public static final Integer CERT_RATE3 =SystemConfig.getConfig("CertRate3", 1000);
    public static final Integer SLEEP_RATE3 =SystemConfig.getConfig("SleepRate3", 2);
    public static final Integer SLOW_SQL_RATE3 =SystemConfig.getConfig("SLOW_SQL_RATE3", 2);

    public static final Integer ERROR_RATE4 =SystemConfig.getConfig("ErrorRate4", 30);
    public static final Integer CERT_RATE4 =SystemConfig.getConfig("CertRate4", 1000);
    public static final Integer SLEEP_RATE4 =SystemConfig.getConfig("SleepRate4", 2);
    public static final Integer SLOW_SQL_RATE4 =SystemConfig.getConfig("SLOW_SQL_RATE4", 2);

    public static final Integer ERROR_RATE5 =SystemConfig.getConfig("ErrorRate5", 30);
    public static final Integer CERT_RATE5 =SystemConfig.getConfig("CertRate5", 1000);
    public static final Integer SLEEP_RATE5 =SystemConfig.getConfig("SleepRate5", 2);
    public static final Integer SLOW_SQL_RATE5 =SystemConfig.getConfig("SLOW_SQL_RATE5", 2);




    public static final String ROOT_APP =SystemConfig.getConfig("ROOTAPP", "");
    public static final String DATABASE1 =SystemConfig.getConfig("DATABASE1", "");
    public static final String DATABASE2 =SystemConfig.getConfig("DATABASE2", "");
    public static final String APP1 =SystemConfig.getConfig("APP1", "");
    public static final String APP2 =SystemConfig.getConfig("APP2", "");
    public static final String APP3 =SystemConfig.getConfig("APP3", "");
    public static final String APP4 =SystemConfig.getConfig("APP4", "");
    public static final String APP5 =SystemConfig.getConfig("APP5", "");

    public static final String QUERY ="Query.do";
    public static final String ADD = "Add.do";
    public static final String UPDATE ="Update.do";
    public static final String Delete ="Delete.do";

    public static final String TABLE_ONE =SystemConfig.getConfig("TABLE_ONE", "");
    public static final String TABLE_TWO = SystemConfig.getConfig("TABLE_TWO", "");
    public static final String TABLE_THREE =SystemConfig.getConfig("TABLE_THREE", "");
    public static final String TABLE_FOUR =SystemConfig.getConfig("TABLE_FOUR", "");


//    public static final boolean HBASE_CONNECT_IS_KEYTAB = SystemConfig.getConfig("hbase.connect.is.keytab", "false").equals("true") ? true:false;


//    private SimpleProperty SYSTEM_PROPERTY = SystemProperty.INSTANCE;

    public void setProperties(Properties properties) {
        this.properties = properties;
    }




    private String readString(Properties properties, String propertyName, String defaultValue) {
        final String result = properties.getProperty(propertyName, defaultValue);
        if (logger.isInfoEnabled()) {
            logger.info("{}={}", propertyName, result);
        }
        return result ;
    }

    public String getRequestUrl() {
        return requestUrl;
    }


}
